home *** CD-ROM | disk | FTP | other *** search
/ boe.pres.k12.wv.us / boe.pres.k12.wv.us.zip / boe.pres.k12.wv.us / Utilities / Xerox Workcentre 5335 / Windows Scan / 32-bit_x86 / Francais / cpsimage.cab / data / docio / findchecksums.elf < prev    next >
Text File  |  2009-03-16  |  2KB  |  76 lines

  1. // ELF script that checksums for all files in a directory
  2.  
  3. /* @findchecksums
  4. // DESCRIPTION
  5. A utility to report the checksum(s) of a file or directory of files.
  6.  
  7. // PARAMETERS
  8. The following parameters may be used:
  9.  
  10. STRING source - The name of a file or directory. This is required. Given a file,
  11. this script will report its checksum using the DOCUMENTREADER. Given a directory,
  12. this script will report checksums for every file it can.
  13. */
  14.  
  15.  
  16. /**********************************************************************************/
  17. /*****************************   SCRIPT ENTRY *************************************/
  18. /**********************************************************************************/
  19. #import "documentio.ucm";
  20. #load "sys/stdio.elf";
  21. LoadClasses(filename:"xeng");
  22.  
  23.  
  24. IMPORT STRING source;
  25. if (!source) {
  26.     print "findchecksums: A source is required.";
  27.     return;
  28. }
  29.  
  30. FILE sourceFILE;
  31. sourceFILE= new(FILE, path: source);
  32. if (sourceFILE.exists() == FALSE) {
  33.     print  "findchecksums: Not able to find "+source;
  34.     return;
  35. }
  36.  
  37. LIST files;
  38. if (sourceFILE.isDirectory() == TRUE) {
  39.     files = sourceFILE.listFiles();
  40. } else if (sourceFILE.exists() == TRUE) {
  41.     files.insert(entry: 0, obj:sourceFILE);
  42. }
  43.  
  44. INTEGER fileCount = files.length();
  45. if (fileCount < 1) {
  46.     print "findchecksums: Zero files found in " + source;
  47.     return;
  48. }
  49.  
  50. DOCUMENTREADER tdr;
  51. INTEGER iLoop;
  52. FILE curFile;
  53. STRING fname;
  54. STRING format;
  55. INTEGER pageCount = 0;
  56. INTEGER sum;
  57. for (iLoop = limit; iLoop < fileCount; iLoop++) {
  58.     curFile = files[iLoop];
  59.     fname = curFile.getName();
  60.     tdr = CreateDocumentReader(filename: curFile.getCanonicalPath() );
  61.     if (tdr) {
  62.         pageCount = tdr.getPageCount();
  63.         sum = tdr.getChecksum();
  64.         tdr.getFormat() Returns(format: format);
  65.         tdr.release();
  66.     } else {
  67.         pageCount = 0;
  68.         sum = 0;
  69.         format = "unknown";
  70.     }
  71.     print fname+" fmt = "+format+" pgs = "+pageCount+" pgs = "+sum;
  72. }
  73.  
  74.  
  75. return;
  76.